<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#Video player script using jwplayer 5.7

#important includes
include 'includes/config.php';
include 'includes/database.class.php'; 

#create database connection
$database = new Database();
$database->connect();

#finish includes
include 'includes/core.class.php';
include 'includes/analytics.class.php';
include 'includes/settings.class.php';
include 'includes/page.class.php';

#vars, classes
$page = new Page();
$analytics = new Analytics();
$settings = new Settings();
$core = new Core();
$searchid = null;

#load style
$stylepath = $settings->loadStyle();
include ("style/" . $stylepath . "/styleinfo.php");

#analytics
$analytics->logVisitor();

#settings
if ($settings->videoGalleryEnabled())
{
	$custom = $page->getMenuCode();
	$custom .= '<li><a href="videogallery">Video Gallery</a></li>';
}
else
{
	$custom = $page->getMenuCode();
}

#get external page name
if (isset($_GET['p']))
{
	$searchname = $core->filter(urldecode($_GET['p']));
}

#check if page exists
$checkBool = $page->checkIfExists($searchname);
if ($checkBool == false)
{

	
	header ("Location: 404error");
}
else
{

#get page by name
$reqpage = array();
$reqpage = $page->getByName($searchname);
$pagehtml = $page->getHTMLCode($reqpage);
$metatags = $page->getMetaTags($reqpage);

#template
$smarty->assign("stylecss", $stylepath);
$smarty->assign("webname", $settings->getWebsiteName());
$smarty->assign("pagename", $reqpage['title']);
$smarty->assign("articles", $pagehtml);
$smarty->assign("headertext", $reqpage['title']);
$smarty->assign("stylename", $stylename);
$smarty->assign("styleauthor", $author);
$smarty->assign("authorwebsite", $authorwebsite);
$smarty->assign("custom", $custom);
$smarty->assign("metatags", $metatags);
$smarty->display("seoheader.tpl");
$smarty->display("menu.tpl");
$smarty->display("index.tpl");
$smarty->display("footer.tpl");
}


?>